const HOST_URL = 'http://localhost:3000'
export const foo = (params={})=> {
    return new Promise((resolve,reject)=>{
      wx.request({
        url: `${HOST_URL}`,
        method: "POST",
        data:{...params},
        success(data){
          resolve(data)
        },
        fail(err){
          reject(err)
        }
      })
    })
}
// 注册账号
export const register = (params={})=> {
  return new Promise((resolve,reject)=>{
    wx.request({
      url: `${HOST_URL}/api/user/register`,
      method: "POST",
      data:{...params},
      success(data){
        resolve(data.data)
      },
      fail(err){
        reject(err)
      }
    })
  })
}
// 登录账号
export const login = (params={})=> {
  return new Promise((resolve,reject)=>{
    wx.request({
      url: `${HOST_URL}/api/user/login`,
      method: "POST",
      data:{...params},
      success(data){
        resolve(data.data)
      },
      fail(err){
        reject(err)
      }
    })
  })
}
// 获取账号信息
export const getUserInfo = (params={})=> {
  return new Promise((resolve,reject)=>{
    wx.request({
      url: `${HOST_URL}/api/user/info`,
      method: "POST",
      data:{...params},
      success(data){
        resolve(data.data)
      },
      fail(err){
        reject(err)
      }
    })
  })
}
// 添加车辆信息
export const vehicle_add = (params={})=> {
  return new Promise((resolve,reject)=>{
    wx.request({
      url: `${HOST_URL}/api/vehicle/add`,
      method: "POST",
      data:{...params},
      success(data){
        resolve(data.data)
      },
      fail(err){
        reject(err)
      }
    })
  })
}
// 获取车辆信息
export const vehicle_info = (params={})=> {
  return new Promise((resolve,reject)=>{
    wx.request({
      url: `${HOST_URL}/api/vehicle/info`,
      method: "POST",
      data:{...params},
      success(data){
        resolve(data.data)
      },
      fail(err){
        reject(err)
      }
    })
  })
}
// 删除车辆信息
export const vehicle_remove = (params={})=> {
  return new Promise((resolve,reject)=>{
    wx.request({
      url: `${HOST_URL}/api/vehicle/remove`,
      method: "POST",
      data:{...params},
      success(data){
        resolve(data.data)
      },
      fail(err){
        reject(err)
      }
    })
  })
}

// 开通钱包
export const wallet_create = (params={})=> {
  return new Promise((resolve,reject)=>{
    wx.request({
      url: `${HOST_URL}/api/wallet/create`,
      method: "POST",
      data:{...params},
      success(data){
        resolve(data.data)
      },
      fail(err){
        reject(err)
      }
    })
  })
}

// 给钱包充值
export const wallet_recharge = (params={})=> {
  return new Promise((resolve,reject)=>{
    wx.request({
      url: `${HOST_URL}/api/wallet/recharge`,
      method: "POST",
      data:{...params},
      success(data){
        resolve(data.data)
      },
      fail(err){
        reject(err)
      }
    })
  })
}

// 费用支出
export const wallet_payout = (params={})=> {
  return new Promise((resolve,reject)=>{
    wx.request({
      url: `${HOST_URL}/api/wallet/payout`,
      method: "POST",
      data:{...params},
      success(data){
        resolve(data.data)
      },
      fail(err){
        reject(err)
      }
    })
  })
}

// 获取钱包信息
export const wallet_info= (params={})=> {
  return new Promise((resolve,reject)=>{
    wx.request({
      url: `${HOST_URL}/api/wallet/info`,
      method: "POST",
      data:{...params},
      success(data){
        resolve(data.data)
      },
      fail(err){
        reject(err)
      }
    })
  })
}

// 设置支付密码
export const wallet_modify_paypwd = (params={})=> {
  return new Promise((resolve,reject)=>{
    wx.request({
      url: `${HOST_URL}/api/wallet/modify_paypwd`,
      method: "POST",
      data:{...params},
      success(data){
        resolve(data.data)
      },
      fail(err){
        reject(err)
      }
    })
  })
}

// 获取订单信息
export const fee_record_info = (params={})=> {
  return new Promise((resolve,reject)=>{
    wx.request({
      url: `${HOST_URL}/api/feeRecord/info`,
      method: "POST",
      data:{...params},
      success(data){
        resolve(data.data)
      },
      fail(err){
        reject(err)
      }
    })
  })
}

// 设置订单支付状态
export const fee_record_modify = (params={})=> {
  return new Promise((resolve,reject)=>{
    wx.request({
      url: `${HOST_URL}/api/feeRecord/modify`,
      method: "POST",
      data:{...params},
      success(data){
        resolve(data.data)
      },
      fail(err){
        reject(err)
      }
    })
  })
}

// 获取用户停车记录信息
export const parking_record_userlist = (params={})=> {
  return new Promise((resolve,reject)=>{
    wx.request({
      url: `${HOST_URL}/api/parkingRecord/userlist`,
      method: "GET",
      data:{...params},
      success(data){
        resolve(data.data)
      },
      fail(err){
        reject(err)
      }
    })
  })
}

// 设置停车场收入
export const parkingLot_income = (params={})=> {
  return new Promise((resolve,reject)=>{
    wx.request({
      url: `${HOST_URL}/api/parkingLot/income`,
      method: "POST",
      data:{...params},
      success(data){
        resolve(data.data)
      },
      fail(err){
        reject(err)
      }
    })
  })
}

// 搜索订单
export const fee_record_search = (params={})=> {
  return new Promise((resolve,reject)=>{
    wx.request({
      url: `${HOST_URL}/api/feeRecord/search`,
      method: "POST",
      data:{...params},
      success(data){
        resolve(data.data)
      },
      fail(err){
        reject(err)
      }
    })
  })
}

// 判断用户是否登陆
export const isLogin = (params={})=> {
  return new Promise((resolve,reject)=>{
    wx.request({
      url: `${HOST_URL}/api/user/isLogin`,
      method: "POST",
      data:{...params},
      success(data){
        resolve(data.data)
      },
      fail(err){
        reject(err)
      }
    })
  })
}

// 获取停车场车位信息
export const parking_lot_info = (params = {}) => {
  return new Promise((resolve,reject)=>{
    wx.request({
      url: `${HOST_URL}/api/parkingLot/info`,
      method: "POST",
      data:{...params},
      success(data){
        resolve(data.data)
      },
      fail(err){
        reject(err)
      }
    })
  })
}